package com.cjd.common.okhttp3

import com.cjd.common.utils.LogUtils
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.Converter
import retrofit2.Retrofit
import java.lang.reflect.Type

/**
 * @Author chenjidong
 * @email 374122600@qq.com
 * created 2019/12/12
 * description
 */
class FileConverterFacory : Converter.Factory() {

    companion object {
        fun create() = FileConverterFacory()
    }

    override fun responseBodyConverter(
        type: Type,
        annotations: Array<Annotation>,
        retrofit: Retrofit
    ): Converter<ResponseBody, *>? {
        for (annotation in annotations) {
            if (annotation is FileConverter) {
                return FileResponseConverter(annotations)
            }
        }
        return super.responseBodyConverter(type, annotations, retrofit)
    }
}